#
# def outer(logo):
#     def inner(msg):
#         print(f"<{logo}><{msg}><{logo}>")
#
#     return inner
#
# fn1 = outer("outer")
# fn1("inner")
# fn1("hello")



# def outer(num1):
#     def inner(num2):
#         #要修改外部变量num1，需要使用nonlocal
#         nonlocal num1
#         num1+=num2
#         print(num1)
#     return inner
#
# fn = outer(10)
# fn(20)

def account_create(initial_amount=0):
    def atm(num,deposit=True):
        nonlocal initial_amount
        if deposit:
            initial_amount +=num
            print(f"额度为{initial_amount}")
        else:
            initial_amount -= num
            print(f"额度为{initial_amount}")

    return atm

atm = account_create(0)
atm(100,True)
atm(50,False)
